package com.hzit.custom;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;


@Component
@Slf4j
public class HzitGlobalGateWayFilter implements GlobalFilter, Ordered {
	//1. 每次发请求（只要通过网关的微服务）都会调用此方法
	@Override
	public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
		log.info("全局网关过滤器正在运行。。。");
		return chain.filter(exchange);      // 放行
	}
	//2. 定义网关过滤器的执行顺序，值越小优先级越高
	@Override
	public int getOrder() {
		return 0;
	}
}
